_package("sample.page");

_import("caf.ui.Page");
_import("caf.ui.MessageBox");
_import("caf.ui.DialogueBox");
_import("caf.ui.Button");

_class("HomePage", Page, function(){
	this._init = function(){
		_super._init.call(this);
	};
	this.create = function(parent){
		//_super.create.apply(this, arguments);
		var obj = this.createTplElement(parent, "home.xml");
		this.init(obj);
		return obj;
	};
	this.init = function(){
		_super.init.apply(this, arguments);
		this.initComponents();
		this.initActionElements();
	};
	this.dispose = function(){
		_super.dispose.apply(this);
	};
	this.do_call_test0 = function(){
		var map = this._components.map1;
		map.addMarker({'coords':'30.238747,120.14532','text':{'content':'2','style':'font-size:12px;color:#fff;','offset':{'x':-3,'y':-38}},'style':{'url':'http://maps.gstatic.com/intl/en_ALL/mapfiles/marker.png','size':{'x':20,'y':34},'anchor':{'x':10,'y':34}},'win':{'title':'三潭映月','content':'西湖十景之十三潭印月是西湖中最大的岛屿'}});
		map.setCenter('30.238747,120.14532,16');
	};
	this.do_call_test1 = function(){
		var map = this._components.map1;
		var cfg = {
			keyword:'肯德基',
			style:{'url':'http://ditu.yahoo.cn/jsapi/res/mapplet.mapplets.alimap.serv.localSearch_bb1.png','size':{'x':29,'y':31},'anchor':{'x':12,'y':31}},
			size:10
		};
		map.startLocalSearch(cfg);
	};
	this.do_call_test2 = function(){
		var map = this._components.map1;
		map.transGeo('上海东方明珠电视塔',m,'coords');
		function m(r){
			console.log(r);
		}
	};
	this.do_call_test3 = function(){
		var map = this._components.map1;
		map.transGeo('39.91435445262867,116.42533706214905',m,'place');
		function m(r){
			console.log(r);
		}
	};
	this.do_call_test4 = function(){
		var map = this._components.map1;
		map.transGeo('39.91435445262867,116.42533706214905',m,'address');
		function m(r){
			console.log(r);
		}
	};
	this.do_call_test5 = function(){
		var map = this._components.map1;
		map._markers[0].depose();
	};
	this.do_call_test6 = function(){
		var map = this._components.map1;
		map.disposeLocalSearch();
	};
	this.do_test = function(act, sender){
		//this.navPage();
		alert("test");
	};
	this.do_call_message = function(act, sender){
		//console.log(document.getElementsByTagName("body")[0])
		var mes = new MessageBox("这是一个Alert", "一些信息一些信息一些信息", "orange");
		mes.create(this._app._contentPane, this._app);
		mes.setReq(runtime._task.add(this, "callback"));
	};
	this.do_call_dialogue = function(act, sender){
		var dlg = new DialogueBox("网络错误", "未联网，点击确定开始链接网络", this, "callback");
		dlg.create(this._app._contentPane, this._app);
		//dlg.customContent("<h1>asdasdasd</h1>");
	};
	this.callback = function(){
		alert(111111111);
	};
});